package com.xiaoshuidi.cloud.module.member.mapper.coupon;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xiaoshuidi.cloud.module.member.api.coupon.vo.CouponCustomerInfoVo;
import com.xiaoshuidi.cloud.module.member.controller.admin.coupon.vo.CouponCustomerPageForm;
import com.xiaoshuidi.cloud.module.member.controller.app.coupon.vo.CouponCustomerVo;
import com.xiaoshuidi.cloud.module.member.pojo.coupon.CouponCustomerEntity;
import com.xiaoshuidi.cloud.module.member.controller.app.coupon.vo.CouponCustomerValidQueryVo;
import com.xiaoshuidi.cloud.module.member.utils.CommonTenantIdVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author Alex
 * @version generator
 * @description 客户优惠券Mapper层
 * @date 2023-03-15 15:02:02
 */
@Mapper
public interface CouponCustomerMapper extends BaseMapper<CouponCustomerEntity> {

    List<CouponCustomerVo> selectCouponByCustomer(@Param("tenantUserId") Long tenantUserId, @Param("usageStatus") Integer usageStatus);

    //查询有效的优惠券
    List<CouponCustomerValidQueryVo> queryAbledCoupon(@Param("tenantUserId") Long tenantUserId, @Param("date") Date date);

    List<CouponCustomerValidQueryVo> queryDisabledCoupon(@Param("tenantUserId") Long tenantUserId, @Param("date") Date date);

    List<CouponCustomerInfoVo> queryByIds(@Param("ids") List ids);

    List<CouponCustomerVo> selectCustomerCouponList(IPage<CouponCustomerVo> page, @Param("form") CouponCustomerPageForm form);

    List<CouponCustomerVo> selectCustomerCouponList(@Param("form") CouponCustomerPageForm form);

    List<CouponCustomerVo> selectTenantCoupons(IPage<CouponCustomerVo> page, @Param("vo") CommonTenantIdVo vo);

    void updateUsageStatus(@Param("list") List<CouponCustomerEntity> list);

    void updateIsLocked(@Param("list") List<CouponCustomerEntity> list);

    List<CouponCustomerValidQueryVo> getCouponCustomerCoupons(@Param("userId") Long tenantUserId);

    List<CouponCustomerValidQueryVo> getCouponCustomerCouponsByIds(@Param("ids") List<Long> ids);

    void updateCouponUsage(@Param("id") Long id);

    void updateCoupon(@Param("id") Long id, @Param("usageTime") Date usageTime);

    void couponUntieLock(@Param("list") List<Long> list);

    void couponAddLock(@Param("id") Long id, @Param("realityPreferentialAmount") BigDecimal realityPreferentialAmount, @Param("lockedTime") Date lockedTime,
                       @Param("lockedDuration") int lockedDuration, @Param("relevanceBill") String relevanceBill, @Param("relevanceContract") String relevanceContract, @Param("billNo") String billNo);

    void updateUserId(@Param("oldUserId") Long oldUserId, @Param("userId") Long userId, @Param("userName") String userName, @Param("mobile") String mobile);
    List<CouponCustomerVo> getCouponsByBill(@Param("billId") String billId);
}
